<?php

namespace app\controller\api\index;

use app\controller\api\ApiBaseController;
use think\facade\Session;


class IndexController extends ApiBaseController
{
    public function index()
    {
        return $this->success('index');
    }
    public function miss()
    {
        return $this->error('no route');
    }
    public function captcha()
    {
        $last_captcha_token = $this->request->param('last_captcha_token', '');
        if ($last_captcha_token) {
            Session::setId($last_captcha_token);
        }

        $verify = \think\captcha\facade\Captcha::create('apiCaptcha');
        return $this->success(
            'success',
            [
                'captcha' => $verify['img'],
                'captcha_token' => Session::getId(),
            ]
        );
    }
}
